package com.xdclass.mysql.config;

import com.xdclass.mysql.interceptor.QueryInterceptor2;
import org.apache.ibatis.session.SqlSessionFactory;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.List;

//@Configuration
//@AutoConfigureAfter(PageHelperAutoConfiguration.class)
public class QMybatisConfig {

    @Resource
    private List<SqlSessionFactory> sqlSessionFactories;

    @PostConstruct
    public void addInterceptor(){
        QueryInterceptor2 queryInterceptor2 = new QueryInterceptor2();
        sqlSessionFactories.forEach(obj ->
                obj.getConfiguration().addInterceptor(queryInterceptor2));
    }
}
